{template 'common/header-gw'}
<ol class="breadcrumb">
	<li><a href="./?refresh"><i class="fa fa-home"></i></a></li>
	<li><a href="{url 'system/welcome'}">用户管理</a></li>
	<li><a href="{url 'user/group'}">用户组</a></li>
	<li class="active">{if $do == 'display'}用户组列表{elseif $do == 'post'}{if $id}编辑{else}添加{/if}用户组{/if}</li>
</ol>
<ul class="nav nav-tabs">
	<li {if $do == 'display'}class="active"{/if}><a href="{php echo url('user/group/display');}">用户组列表</a></li>
	<li {if $do == 'post'}class="active"{/if}><a href="{php echo url('user/group/post');}">{if $id}编辑{else}添加{/if}用户组</a></li>
</ul>
{if $do == 'post'}

<div class="clearfix">
	<form action="" method="post"  class="form-horizontal" role="form" enctype="multipart/form-data" onsubmit="return formcheck(this)">
		<h5 class="page-header">用户组管理</h5>
		<input type="hidden" name="id" value="{$id}" />
		<input type="hidden" name="templateid" value="{$template['id']}">
		<div class="form-group">
			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">名称</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" name="name" id="name" value="{$group['name']}" />
			</div>
		</div>
		
		<h5 class="page-header">设置可使用的功能权限</h5>
		
		<table class="table table-hover">
			<thead class="navbar-inner">
            <tr>
                <th style="width:40px;" class="row-first">&nbsp;</th>
                <th>模块</th>
                <th>可见</th>
                <th>增加</th>
                <th>修改</th>
                <th>删除</th>
                <th>审核</th>
            </tr>
			</thead>
			<tbody>
				<tr>
                    <td class="row-first"><input type="checkbox" rel="12" class="check_all" name="check_leads"/></td>
                    <td>监测通知</td>
                    <td><input {if in_array('plan/disp', $owned_permission) } checked="checked" {/if} class="check_list12" type="checkbox" name="per[]" value="plan/disp"></td>
                    <td><input {if in_array('plan/add', $owned_permission) } checked="checked" {/if} class="check_list12" type="checkbox" name="per[]" value="plan/add"></td>
                    <td><input {if in_array('plan/edit', $owned_permission) } checked="checked" {/if} class="check_list12" type="checkbox" name="per[]" value="plan/edit"></td>
                    <td><input {if in_array('plan/delete', $owned_permission) } checked="checked" {/if} class="check_list12" type="checkbox" name="per[]" value="plan/delete"></td>
                    <td><input {if in_array('plan/audit', $owned_permission) } checked="checked" {/if} class="check_list12" type="checkbox" name="per[]" value="plan/audit"></td>
				</tr>
                <tr>
                    <td class="row-first"><input type="checkbox" rel="13" class="check_all" name="check_leads"/></td>
                    <td>拨款凭证信息</td>
                    <td><input {if in_array('grant/disp', $owned_permission) } checked="checked" {/if} class="check_list13" type="checkbox" name="per[]" value="grant/disp"></td>
                    <td><input {if in_array('grant/add', $owned_permission) } checked="checked" {/if} class="check_list13" type="checkbox" name="per[]" value="grant/add"></td>
                    <td><input {if in_array('grant/edit', $owned_permission) } checked="checked" {/if} class="check_list13" type="checkbox" name="per[]" value="grant/edit"></td>
                    <td><input {if in_array('grant/delete', $owned_permission) } checked="checked" {/if} class="check_list13" type="checkbox" name="per[]" value="grant/delete"></td>
                    <td><input {if in_array('grant/audit', $owned_permission) } checked="checked" {/if} class="check_list13" type="checkbox" name="per[]" value="grant/audit"></td>
                </tr>
                <tr>
                    <td class="row-first"><input type="checkbox" rel="14" class="check_all" name="check_leads"/></td>
                    <td>库款划拨信息</td>
                    <td><input {if in_array('finance/disp', $owned_permission) } checked="checked" {/if} class="check_list14" type="checkbox" name="per[]" value="finance/disp"></td>
                    <td><input {if in_array('finance/add', $owned_permission) } checked="checked" {/if} class="check_list14" type="checkbox" name="per[]" value="finance/add"></td>
                    <td><input {if in_array('finance/edit', $owned_permission) } checked="checked" {/if} class="check_list14" type="checkbox" name="per[]" value="finance/edit"></td>
                    <td><input {if in_array('finance/delete', $owned_permission) } checked="checked" {/if} class="check_list14" type="checkbox" name="per[]" value="finance/delete"></td>
                    <td><input {if in_array('finance/audit', $owned_permission) } checked="checked" {/if} class="check_list14" type="checkbox" name="per[]" value="finance/audit"></td>
                </tr>
			</tbody>
		</table>
		<div class="form-group">
			<div class="col-sm-offset-2 col-md-offset-2 col-lg-offset-1 col-xs-12 col-sm-10 col-md-10 col-lg-11">
				<input name="token" type="hidden" value="{$_W['token']}" />
				<input type="submit" class="btn btn-primary span3" name="submit" value="提交" />
			</div>
		</div>
	</form>
</div>

{elseif $do == 'display'}

<form action="" method="post">
<div class="clearfix">
	<table class="table table-hover">
		<thead class="navbar-inner">
			<tr>
				<th style="width:30px;">删？</th>
				<th style="width:150px;">名称</th>
				<th style="min-width:60px;">操作</th>
			</tr>
		</thead>
		<tbody>
			{loop $list $item}
			<tr>
				<td><input type="checkbox" name="delete[]" value="{$item['id']}" /></td>
				<td>{$item['name']}</td>
				<td><span><a href="{php echo url('user/group/post', array('id' => $item['id']))}">编辑</a></span></td>
			</tr>
			{/loop}
		</tbody>
		<tr>
			<th></th>
			<td>
				<input name="token" type="hidden" value="{$_W['token']}" />
				<input type="submit" class="btn btn-primary span3" name="submit" value="提交" />
			</td>
		</tr>
	</table>
</div>
</form>
{/if}
<script type="text/javascript">
    require(['jquery'],function($){

        $(".check_all").click(function(){
            var rel = $(this).attr('rel');
            $("input[class='check_list"+rel+"']").prop('checked', $(this).prop("checked"));
        });
    });
</script>
{template 'common/footer-gw'}